package com.alb;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class RedBook2_2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        List<Node> nodes=new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int likes=scanner.nextInt();
            nodes.add(new Node(likes));
        }
        for (int i = 0; i < n; i++) {
            int comments=scanner.nextInt();
            nodes.get(i).setComments(comments);
        }
        Collections.sort(nodes,(a, b)->b.likes-a.likes);
        long maxAns=0;
        for (int i = 0; i <= n - k; i++) {
            int minComments=Integer.MAX_VALUE;
            long totalLikes=0;
            for(int j=i;j<i+k;j++){
                minComments=Math.min(minComments,nodes.get(j).comments);
                totalLikes+=nodes.get(j).likes;
            }
            maxAns=Math.max(maxAns,totalLikes*minComments);
        }
        System.out.println(maxAns);
    }
    static class Node{
        int likes;
        int comments;
        public Node(int likes){
            this.likes=likes;
        }

        public void setComments(int comments){
            this.comments=comments;
        }
    }
}
